package machine;

import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JPanel;

class RegisterBankGUI extends JPanel
{

    private RegisterGUI regs[];
    static private int numRegisters;

    public RegisterBankGUI(int numRegisters)
    {
        this.numRegisters = numRegisters;

        regs = new RegisterGUI[numRegisters];
        
        ((Container)this).setLayout(((java.awt.LayoutManager) (new GridLayout(numRegisters, 1, 1, 1))));
        for(int i = 0; i<numRegisters; i++)
        {
            regs[i] = new RegisterGUI(" R" + i + ":");
            ((Container)this).add(((java.awt.Component) (regs[i])));
        }

        for(int j = 10; j < numRegisters; j++)
        {
            regs[j] = new RegisterGUI("R" + j + ":");
            ((Container)this).add(((java.awt.Component) (regs[j])));
        }

    }

    public void set(RegisterBank registerbank)
    {
        for(int i = 0; i < numRegisters; i++)
        {
            regs[i].set(registerbank.read(Integer.toBinaryString(i)));
        }

    }

}
